import { computed } from 'vue';
import { useStore } from 'vuex';
import { RootState } from '@/store/interface';
import { moduleActionDispatchMap } from "./useModuleActionDispatchMap"

/**
 * @description 返回拥有类型的 store 仓库（类型主要针对 state）
 * @returns state 仓库数据、dispatch 方法
 */
const useMyStore = () => {
    // 拥有类型的仓库(state 默认 any)
    const store = useStore<RootState>();

    // state 仓库数据
    const state = computed(() => store.state);

    // dispatch 方法
    const dispatch = store.dispatch;

    return {
        state,
        dispatch
    };
}

export {
    useMyStore as useStore,
    moduleActionDispatchMap
}